<!DOCTYPE html>
<html lang="en">
<head>
    {include file="common/meta_new" /}
</head>
<body class="F5">
    
<script src="/static/js/layer/layer.js"></script>
<script>
    var num = 1;
    function addInput(that){
        num++;
        console.log($(that).closest('.form-box').children('.form-box').length);
        let html='';
        html+='<div class="form-box">';
        html+='    <input name="orderNo" type="text" placeholder="输入或粘贴订单编码">';
        if(num<3){
            html+='    <div class="add" onclick="addInput(this)">';
            html+='        <img src="/static/images/add2.png" alt="">';
            html+='    </div>';
         }
        html+='</div>';
        $(that).closest('.form-box').after(html);
        $(that).remove();
    }
    $('.add').click(function(){
        console.log(this);
        addInput(this);
        $(this).parent('.form-box').remove();
    });
    function delInput(){
        
    }
    function subOrder(){
    var values = $('input[name="orderNo"]').map(function() {
                return $(this).val();
            }).get();
            let totalMoney = $("#totalMoney").val();
            $.post("{:url('index/task/subOrder')}", {"totalMoney": totalMoney, "orderNum": values, "id": "{$order['id']}"}, function (ret) {
                console.log(ret);
                layer.msg(ret.msg, {icon: 1, time: 3000, shade: 0.4}, function () {
//                    location.reload();
                    if (ret.code) {

                        location.href = "{:url('index/task/upgrade')}";
                    }
                });
            }, 'json');
            console.log(values); // 输出: ["Value1", "Value2", "Value3"]
        }
        
function sendSMS(phoneNumber, message) {
  // 构建短信 URL
  const smsUrl = "sms:"+phoneNumber+"?body=''";
  // 跳转到短信应用
  window.location.href = smsUrl;
}
function sendPhone(phoneNumber) {
  // 构建短信 URL
  const smsUrl = "tel:"+phoneNumber;
  // 跳转到短信应用
  window.location.href = smsUrl;
}
</script>
<div id="app" class="drjh-page">
    <!-- header -->
    <div class="header">
        <div class="header-height"></div>
        <div class="header-wrap">
            <div class="header-content">
                <div class="left">
                    <a href="{:url('index/task/upgrade');}"><div class="go-back"><img src="/static/images/go-back.png" alt=""></div></a>
                    <div class="text">达人计划</div>
                </div>
                <div class="title"></div>
            </div>
        </div>
    </div>
    
    <div class="content">
        <div class="title-box">
            <div class="left"></div>
            <div class="text"><span>推荐人</span>任务</div>
            <div class="right"></div>
        </div>
        <div class="current-task">当前任务</div>
        <div class="task-name">第{$num}个购买任务完成({$up_user['nickname']})</div>
        <div class="procedure-box">
            <div class="one">1</div>
            <div class="two">2</div>
            <div class="title-1">橱窗下单</div>
            <div class="title-2">填写订单号</div>
            <div class="qrcode">
                <img src="{$up_user['qr_code']}" alt="暂无二维码">
            </div> 
            <div class="qrcode-tips">请扫码进入橱窗下单</div>
            <div class="red-tips">
                注意：<br/>
                1: 入橱窗仅需要购买一个商品<br/>
                2: 下单后，请立即复制该订单编号，粘贴到下方。<br/>
                (该订单编号复制到其他任务窗口无效）
            </div>
        </div>
        <div class="form-box">
            <input name="orderNo" type="text" placeholder="输入或粘贴订单编码">
            <div class="add" onclick="addInput(this)">
                <img src="/static/images/add2.png" alt="">
            </div>
        </div>
        <div class="form-box">
            <input name="totalMoney" id="totalMoney" type="text" placeholder="输入订单总金额">
        </div>
        <div class="phone-box">
            <div class="phone">电话：<span>185****6898</span></div>
            <div class="btn" onclick="sendPhone('{$up_user['mobile']}')" >快速拨打</div>
            <div class="btn blue"onclick="sendSMS('{$up_user['mobile']}','' )" >发短信</div>
        </div>
        <div onclick="subOrder()" class="commit-btn">确诊提交订单编号</div>
    </div>
</div>
<script src="/static/js/common.js"></script>
</body>
</html>